﻿@model UserDetailModel
@inject IMenuProvider Menu
@{
    ViewData["Title"] = "User u" + Model.User.Id;
    var additions = Model.Additions.ToLookup(a => a.Category);
}

<h2 class="mt-2">@ViewData["Title"]</h2>

<div class="row">
    <div class="col-lg-4">
        <table class="table table-sm table-striped">
            <tr><th>ID</th><td>u@(Model.User.Id)</td></tr>
            <tr><th>Login</th><td class="text-monospace text-small">@Model.User.UserName</td></tr>
            <tr><th>Nick name</th><td>@Model.User.NickName</td></tr>
            <tr><th>Email @(Model.User.EmailConfirmed ? "" : "?")</th><td>@Model.User.Email</td></tr>
            <tr><th>Password</th><td>@(Model.User.HasPassword() ? "Set" : "Not set")</td></tr>
            <tr><th>Register date</th><td>@Html.CstTime(Model.User.RegisterTime)</td></tr>
            <tr><th>Plan</th><td>@Model.User.Plan</td></tr>
        </table>
    </div>
    <div class="col-lg-4">
        <table class="table table-sm table-striped">
            @foreach (var category in additions)
            {
                bool showBr = !category.Key.EndsWith(" of");
            <tr>
                <th>@category.Key</th>
                <td>
                    @foreach (var item in category)
                    {
                        var url = item.GetUrl(Url);
                        <a asp-show-if="url != null" href="@url" title="@item.Title">@item.Text</a>
                        <span asp-show-if="url == null" title="@item.Title">@item.Text</span>
                        <br asp-show-if="showBr" />
                    }
                </td>
            </tr>
            }
        </table>
    </div>
</div>

<div class="mb-4">
    <p>
        <a asp-route-uid="@Model.User.Id" asp-action="Edit" class="btn btn-primary" title="Edit"><i class="fas fa-edit"></i>&nbsp;Edit</a>
    </p>
</div>

@await Menu.Extend(SatelliteSite.IdentityModule.ExtensionPointDefaults.DashboardUserDetail).RenderAsync(Component)
